﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using LightWeightORM.ORM.TableAccessor;
using SmartWarehouse.Common;
using SmartWarehouse.ORM.Entity;
using SmartWarehouse.Config;


namespace SmartWarehouse
{
    namespace BussinessLogic
    {
        namespace Basis
        {
            /// <summary>
            /// Summary description for RightFacade
            /// </summary>
            public class RightFacade
            {
                private TableAccessor<SwRight> _rightAccessor;

                public TableAccessor<SwRight> RightAccessor
                {
                    get { return _rightAccessor; }
                    set { _rightAccessor = value; }
                }
                public RightFacade()
                {
                    this.RightAccessor = AccessorFactory.RightAccessor;
                }

                public SwRight[] GetUserPages(string userName)
                {
                    TableAccessor<SwUser> userAccessor = new TableAccessor<SwUser>(ConfigUtility.DbConnectionString);
                    SwUser user = userAccessor.GetOne(new Filter(SwUser._Name, userName, ComparisonOperator.Equal));

                    SwRight[] rights = this.RightAccessor.GetMuch(new Filter(SwRight._Role_name, user.Role, ComparisonOperator.Equal));

                    return rights;
                }
            }
        }
    }
}